


<cftransaction>

<cfoutput>


<cfif not isdefined("session.receiptnum")>
<!---<CFQUERY NAME="checkrenum" DATASOURCE="#dsn#">
select * 
from tblorders
WHERE   OrderID = (SELECT MAX(OrderID)  FROM tblorders)
</CFQUERY>


<cfset session.ReceiptNum = "#checkrenum.ReceiptNum#">--->






<cfelse>




<CFQUERY NAME="checkfour" DATASOURCE="#dsn#">
select * 
from tblorders
WHERE   ReceiptNum = #session.ReceiptNum#
</CFQUERY>

<cfif #checkfour.lastfour# eq "">

<cfquery datasource="#dsn#">
delete
from tblorders
where ReceiptNum = #session.ReceiptNum#
</cfquery>

<cfquery datasource="#dsn#">
delete
from tbltransactions
where ReceiptNum = #session.ReceiptNum#
</cfquery>

</cfif>

</cfif>

</cfoutput>



<cflock timeout=20 scope="Session" type="Exclusive">

<cfset structdelete(SESSION, "ReceiptNum")>
<cfset structdelete(SESSION, "type")>
<cfset structdelete(SESSION, "CARTID")>
<cfset structdelete(SESSION, "nothanks")>
<cfset structdelete(SESSION, "KEYID")>
<cfset structdelete(SESSION, "location")>
<cfset structdelete(SESSION, "DODAAC")>

</cflock>

</cftransaction>


<cflocation url="index.cfm">
